(module-name <ammunerve.scm.main>)
(require <console.scm.manager>)
(require <console.scm.console>)
(require <console.scm.action>)


(define exit-action (make-action (lambda (arg action) (exit)) "Exit"  (java.awt.event.KeyEvent:.VK_X)))
(define load-script-file-action (make-action load-script-file "Run Scheme Script" (java.awt.event.KeyEvent:.VK_R)))

(define show-all-action (make-action (lambda (arg action) (task-show-all) (task-state arg STATE_DONE)) "show all" (java.awt.event.KeyEvent:.VK_V)))
(define clear-all-action (make-action (lambda (arg action) (task-clear-all)(task-show-all)) "clear all" (java.awt.event.KeyEvent:.VK_C)))
;(define show-about-action (make-action show-about "About" (java.awt.event.KeyEvent:.VK_A)))

(define base-menu
  (list
    (list "File" (java.awt.event.KeyEvent:.VK_F)
       load-script-file-action
       exit-action)
;    (list "Task Manager" (java.awt.event.KeyEvent:.VK_V)
;       show-all-action
;       clear-all-action)
))

(define (init-properties)
;	(action-properties item-properties item-properties-list)
	(action-init)
;  (action-add item-action)
	(action-refresh))

;;; -- main entry point --- ;;;
(make-frame)
;(let ((appLock (<console.AppLock> "Console_Lock")))
;  (if (appLock:isAppActive)
;    (begin
;      (javax.swing.JOptionPane:showMessageDialog
;        frame
;        "Another Console is already open or failed to close properly (it may need to be killed manually)"
;        "Console already open"
;        (javax.swing.JOptionPane:.ERROR_MESSAGE))
;      (if (appLock:isAppActive)
;        (exit)))))
(make-menu base-menu)
;(init-properties)
;(console.manager.TaskPanel frame)
;(add-tabs frame top-panel)
(if (file-exists? "scripts/startup.scm")
  (begin
    (in_r:append "(load \"scripts/startup.scm\")")
    (display "console initialized")
    (newline)
    ;(set-input-port-prompter! (current-input-port) console-prompter)
    (in_r:append "\n")))
;;; --- while(1) --- ;;;
(letrec ((next (lambda ()
                 ;(sleep (java.lang.Integer:.MAX_VALUE))
                 (sleep 10000)
                 (next))))
  (next))
